package com.lcm.jnode.controller.admin;

import com.jfinal.aop.Before;
import com.jfinal.core.Controller;
import com.lcm.jnode.interceptor.AdminInterceptor;
import com.lcm.jnode.model.User;

/**
 * 后台用户管理
 * @author L.cm
 * @date 2013-5-31 下午9:52:04
 */
@Before(AdminInterceptor.class)
public class AdminUserController  extends Controller {

	public void index() {
		setAttr("page", User.dao.paginate(getParaToInt(0, 1), 10, "select *",
				"from model order by id asc"));
		render("UserController.html");
	}

	public void add() {
		
	}

	public void save() {
		getModel(User.class).save();
		forwardAction("/model");
	}

	public void edit() {
		setAttr("model", User.dao.findById(getParaToInt()));
	}

	public void update() {
		getModel(User.class).update();
		forwardAction("/model");
	}

	public void delete() {
		User.dao.deleteById(getParaToInt());
		forwardAction("/model");
	}
}
